#!/usr/bin/python
# Prints phylogeny info for rna.
import sys

# parameters.
tammar_file = sys.argv[1]
mondom_file = sys.argv[2]
mouse_file = sys.argv[3]
human_file = sys.argv[4]

## Read in data.
def read_dat(fp):
	# Read.
	fin = open(fp,"rb")
	lines = fin.readlines()
	fin.close()
	
	# pull unique.
	uniq = {}
	for line in lines:
		uniq[line.strip()] = True
	
	# return.
	del lines
	return uniq


# use function.
tammar = read_dat(tammar_file)
mondom = read_dat(mondom_file)
mouse = read_dat(mouse_file)
human = read_dat(human_file)

# shared in all.
cnt = 0
for key in tammar:
	if key in mondom and key in mouse and key in human:
		cnt += 1
print "shared in all:\t%i" % cnt

# shared in eughterian.
cnt = 0
for key in mouse:
	if key in human:
		cnt += 1
print "shared in eutherian:\t%i" % cnt

# shared in marsupial.
cnt = 0
for key in tammar:
	if key in mondom:
		cnt += 1
print "shared in marsupial:\t%i" % cnt

# uniq in marsupial.
cnt = 0
totkeys = tammar.keys() + mondom.keys()
for key in totkeys:
	if key not in human and key not in mouse:
		cnt += 1
print "unique in marsupial:\t%i" % cnt

# uniq in tammar.
cnt = 0
for key in tammar:
	if key not in human and key not in mouse and key not in mondom:
		cnt += 1
print "unique in tammar:\t%i" % cnt
